package CarImpl;

import Dao.carDao;
import baseDao.baseDao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class CarImpl extends baseDao implements carDao {
    @Override
    public List<Car> list() {
        String sql="select * from car";
        ResultSet rs=find(sql,null);
        List<Car> list=new ArrayList<Car>();
        try {
            if (rs.next()){
                Car car=new Car();
                car.setId(rs.getInt(1));
                car.setName(rs.getString(2));
                list.add(car);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
            return list;
    }
}
